package com.mew.chess.core.game.yxx.game.task;

import com.mew.chess.core.common.handler.ChessPushMessageUtil;
import com.mew.chess.core.game.yxx.game.YxxGameManager;
import com.mew.chess.core.game.yxx.game.YxxRoomManager;
import com.mew.chess.core.game.yxx.game.common.YxxLinkType;
import com.mew.chess.core.game.yxx.game.core.YxxRobotBetUtils;
import com.mew.chess.core.game.yxx.game.message.YxxPushBetInfoMessage;
import com.mew.chess.core.game.yxx.game.message.YxxPushCMDMapType;
import com.zebra.common.concurrent.ZebraScheduler;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ScheduledFuture;

@Slf4j
public class YxxPushBetScheduleTask {


    public void robotBet(int roomId, ScheduledFuture<?> stepFuture){
        YxxRoomManager controller = YxxGameManager.getInstance().getController(roomId);
        if (controller.getLinkType() != YxxLinkType.Start.code()){
            if (null != stepFuture){
                ZebraScheduler.cancelScheduled(stepFuture);
            }
            return;
        }

        YxxPushBetInfoMessage betInfoResponse = YxxRobotBetUtils.sumBetNumber(roomId, true);
        //log.info("Yxx push bet Info：us {} {} ", controller.getOnlineUser().size(), betInfoResponse.toString());
        ChessPushMessageUtil.broadcastMessage(controller.getOnlineUser().values(), YxxPushCMDMapType.BetInfoMessage.code(), betInfoResponse);
    }

}
